%%%-------------------------------------------------------------------
%%% @doc  
%%% Copyright (C) 2007, Lucas Carlson
%%% File    : drproxy.erl
%%% Author  : Lucas Carlson (lucas@rufy.com)
%%% @end
%%%-------------------------------------------------------------------
-module(drproxy).

-behaviour(application).
%%--------------------------------------------------------------------
%% Include files
%%--------------------------------------------------------------------
-include("drproxy.hrl").

%%--------------------------------------------------------------------
%% External exports
%%--------------------------------------------------------------------
-export([
	 start/2,
	 shutdown/0,
	 stop/1,
	 status/0,
	 config/1
	 ]).

%%--------------------------------------------------------------------
%% Macros
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Records
%%--------------------------------------------------------------------

%%====================================================================
%% External functions
%%====================================================================
%%--------------------------------------------------------------------
%% @doc The starting point for an erlang application.
%% @spec start(Type, StartArgs) -> {ok, Pid} | {ok, Pid, State} | {error, Reason}
%% @end
%%--------------------------------------------------------------------
start(Type, StartArgs) ->
  case dp_sup:start_link(StartArgs) of
  	{ok, Pid} -> 
      {ok, Pid};
  	Error ->
      Error
  end.

%%--------------------------------------------------------------------
%% @doc Called to shudown the drproxy application.
%% @spec shutdown() -> ok 
%% @end
%%--------------------------------------------------------------------
shutdown() ->
  application:stop(drproxy).

%%--------------------------------------------------------------------
%% @doc Called to get status information for drproxy
%% @spec status() -> ok 
%% @end
%%--------------------------------------------------------------------
status() ->
  dp_server:status().

config(Type) ->
	case config_server:config(Type) of
	  not_found ->
	    error_logger:error_msg("default value not found for key ~w~n", [Type]),
			exit({default_value, not_found});
		Value ->
		  Value
	end.

%%====================================================================
%% Internal functions
%%====================================================================

%%--------------------------------------------------------------------
%% Called upon the termintion of an application.
%%--------------------------------------------------------------------
stop(State) ->
    ok.
